package com.ks.fission.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.fission.controller.dto.BFissionMemberRequest;
import com.ks.fission.controller.dto.BFissionTaskRequest;
import com.ks.fission.entity.BFissionTask;
import com.ks.fission.service.IBFissionLogService;
import com.ks.fission.service.IBFissionTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 裂变-新会员被成功邀请注册的记录 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/bFissionLog")
@Api(value = "分享裂变邀请成功记录模块", description = "分享裂变邀请成功模块")
public class BFissionLogController extends _ControllerBase {

    @Resource
    private IBFissionLogService ibFissionLogService;
    @Autowired
    private IBFissionTaskService ibFissionTaskService;

    @PostMapping("/insertIBFissionLog")
    @ApiOperation(value = "应用端邀请注册接口", notes = "phone(手机号),memberId(分享人会员id),iTaskId(任务id)")
    public Object insertIBFissionLog(@RequestBody BFissionMemberRequest bFissionMemberRequest) {
        int i = ibFissionLogService.insertIBFissionLogService(getContext(), bFissionMemberRequest);
        return Result.success(i);
    }

    @PostMapping("/selectIBFissionLogList")
    @ApiOperation(value = "管理端成功分享清单查询接口", notes = "管理端成功分享清单查询接口")
    public Object selectIBFissionLogList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = ibFissionLogService.selectIBFissionLogList(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/selectLogList")
    @ApiOperation(value = "应用端分享记录接口", notes = "应用端分享记录接口")
    public Object selectLogList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = ibFissionLogService.selectLogList(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/getBFissionInfo")
    @ApiOperation(value = "分享裂变任务详情接口", notes = "分享裂变任务详情接口")
    public Object getBFissionInfo(@RequestBody BFissionTaskRequest request) {
        BFissionTask bFissionTask = ibFissionTaskService.getBFissionTaskInfo(request.getId());
        return Result.success(bFissionTask);
    }

}

